home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / dev / mui / MCC_SpeedBar.lha / MCC_SpeedBar / Developer / C / Examples / demo4.c < prev    next >
C/C++ Source or Header  |  2002-06-13  |  6KB  |  162 lines

  1.  
  2. #include <proto/exec.h>
  3. #include <proto/dos.h>
  4. #include <proto/muimaster.h>
  5. #include <clib/alib_protos.h>
  6. #include <mui/SpeedBar_mcc.h>
  7. #include <mui/SpeedBarCfg_mcc.h>
  8. #include <string.h>
  9. #include <stdio.h>
  10.  
  11. /***********************************************************************/
  12.  
  13. long __stack = 8192;
  14. struct Library *MUIMasterBase;
  15.  
  16. /***********************************************************************/
  17.  
  18. #ifndef MAKE_ID
  19. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  20. #endif
  21.  
  22. /***********************************************************************/
  23.  
  24. struct MUIS_SpeedBar_Button buttons[] =
  25. {
  26.     {0, "_Get", "Get the disc.", 0, NULL},
  27.     {1, "Sa_ve", "Save the disc.", 0, NULL},
  28.     {2, "_Stop", "Stop the connection.", 0, NULL},
  29.     {MUIV_SpeedBar_Spacer},
  30.     {3, "_Disc", "Disc page.", 0, NULL},
  31.     {4, "_Matches", "Matches page.", 0, NULL},
  32.     {5, "_Edit", "Edit page.", 0, NULL},
  33.     {MUIV_SpeedBar_End},
  34. };
  35.  
  36. STRPTR pics[] =
  37. {
  38.     "Get",
  39.     "Save",
  40.     "Stop",
  41.     "Disc",
  42.     "Matches",
  43.     "Edit",
  44.     NULL
  45. };
  46.  
  47. /***********************************************************************/
  48.  
  49. int
  50. main(int argc,char **argv)
  51. {
  52.     int res;
  53.  
  54.     if (MUIMasterBase = OpenLibrary("muimaster.library",19))
  55.     {
  56.         Object                          *app, *win, *hg, *sb, *spc, *cfg, *barSpacer, *update;
  57.         struct MUIS_SpeedBarCfg_Config  c = {MUIV_SpeedBar_ViewMode_TextGfx,MUIV_SpeedBarCfg_Borderless|MUIV_SpeedBarCfg_Sunny};
  58.  
  59.         if (app = ApplicationObject,
  60.                 MUIA_Application_Title,         "SpeedBar Demo4",
  61.                 MUIA_Application_Version,       "$VER: SpeedBarDemo4 14.4 (13.6.2002)",
  62.                 MUIA_Application_Copyright,     "Copyright 1999-2002 by Alfonso Ranieri",
  63.                 MUIA_Application_Author,        "Alfonso Ranieri <alforan@tin.it>",
  64.                 MUIA_Application_Description,   "Speed(Bar|Button|BarCfg).mcc test",
  65.                 MUIA_Application_Base,          "SPEEDBARTEST",
  66.                 SubWindow, win = WindowObject,
  67.                     MUIA_Window_ID,             MAKE_ID('M','A','I','N'),
  68.                     MUIA_Window_Title,          "SpeedBar Demo4",
  69.                     WindowContents, VGroup,
  70.                         Child, hg = HGroup,
  71.                             GroupFrame,
  72.                             Child, sb = SpeedBarObject,
  73.                                 MUIA_Group_Horiz,               TRUE,
  74.                                 MUIA_SpeedBar_Spread,           TRUE,
  75.                                 MUIA_SpeedBar_Borderless,       TRUE,
  76.                                 MUIA_SpeedBar_Sunny,            TRUE,
  77.                                 MUIA_SpeedBar_Buttons,          buttons,
  78.                                 MUIA_SpeedBar_StripUnderscore,  TRUE,
  79.                                 MUIA_SpeedBar_EnableUnderscore, TRUE,
  80.                                 MUIA_SpeedBar_BarSpacer,        TRUE,
  81.                                 MUIA_SpeedBar_PicsDrawer,       "PROGDIR:PICS",
  82.                                 MUIA_SpeedBar_Pics,             pics,
  83.                                 MUIA_SpeedBar_SpacerIndex,      -1,
  84.                             End,
  85.                             Child, spc = HSpace(0),
  86.                         End,
  87.                         Child, VSpace(0),
  88.                         Child, VGroup,
  89.                             GroupFrameT("Appareance"),
  90.                             Child, cfg = SpeedBarCfgObject,
  91.                                 MUIA_SpeedBarCfg_Config, &c,
  92.                             End,
  93.                             Child, HGroup,
  94.                                 Child, Label("BarSpacer"),
  95.                                 Child, barSpacer = MUI_MakeObject(MUIO_Checkmark,NULL),
  96.                                 Child, HSpace(0),
  97.                             End,
  98.                             Child, VSpace(0),
  99.                             Child, update = MUI_MakeObject(MUIO_Button,"_Update"),
  100.                         End,
  101.                         Child, VSpace(0),
  102.                     End,
  103.                 End,
  104.             End)
  105.         {
  106.             ULONG sigs = 0, id;
  107.  
  108.             DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  109.             DoMethod(update,MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,TAG_USER);
  110.  
  111.             set(win,MUIA_Window_Open,TRUE);
  112.             set(barSpacer,MUIA_Selected,TRUE);
  113.  
  114.             while ((id = DoMethod(app,MUIM_Application_NewInput,&sigs))!=MUIV_Application_ReturnID_Quit)
  115.             {
  116.                 if (id==TAG_USER)
  117.                 {
  118.                     struct MUIS_SpeedBarCfg_Config  *c;
  119.                     ULONG                           bs;
  120.  
  121.                     get(cfg,MUIA_SpeedBarCfg_Config,&c);
  122.                     get(barSpacer,MUIA_Selected,&bs);
  123.  
  124.                     SetAttrs(sb,MUIA_SpeedBar_Borderless,c->Flags & MUIV_SpeedBarCfg_Borderless,
  125.                                 MUIA_SpeedBar_RaisingFrame,c->Flags & MUIV_SpeedBarCfg_Raising,
  126.                                 MUIA_SpeedBar_SmallImages,c->Flags & MUIV_SpeedBarCfg_SmallButtons,
  127.                                 MUIA_SpeedBar_Sunny,c->Flags & MUIV_SpeedBarCfg_Sunny,
  128.                                 MUIA_SpeedBar_BarSpacer,bs,
  129.                                 MUIA_SpeedBar_ViewMode,c->ViewMode,
  130.                                 TAG_DONE);
  131.                 }
  132.  
  133.                 if (sigs)
  134.                 {
  135.                     sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  136.                     if (sigs & SIGBREAKF_CTRL_C) break;
  137.                 }
  138.             }
  139.  
  140.             MUI_DisposeObject(app);
  141.  
  142.             res = RETURN_OK;
  143.         }
  144.         else
  145.         {
  146.             printf("%s: can't create application\n",argv[0]);
  147.             res = RETURN_FAIL;
  148.         }
  149.  
  150.         CloseLibrary(MUIMasterBase);
  151.     }
  152.     else
  153.     {
  154.         printf("%s: Can't open muimaster.library ver 19 or higher\n",argv[0]);
  155.         res = RETURN_ERROR;
  156.     }
  157.  
  158.     return res;
  159. }
  160.  
  161. /***********************************************************************/
  162.